package com.mio.hdfs.mytest;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class HDFSClient {
	FileSystem fs = null;
	 Configuration configuration = null;
	@Before
	public void beforTest() throws IOException, InterruptedException, URISyntaxException {
		System.out.println("1 获取文件系统");
		// 1 获取文件系统
		 configuration = new Configuration();
		// 配置在集群上运行
		// configuration.set("fs.defaultFS", "hdfs://linux121:9000"); // FileSystem fs = FileSystem.get(configuration);
		fs = FileSystem.get(new URI("hdfs://linux169:9000"),configuration, "root"); 
	}
	
	@After
	public void afterTest() throws IOException {
		fs.close();
		System.out.println("end");
	}
	
	@Test
	public void testCopyFromLocalFile() throws IllegalArgumentException, IOException {
		fs.copyFromLocalFile(new Path("/Users/mio/Desktop/bdb/test.txt"), new Path("/lagou2.txt"));

	}
	@Test
	public void test2() {
		System.out.println("22");
	}

}
